<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>表格鼠标悬停有高亮显示</title>
		<script>
			function changeColor(id,key){
				if(key == "up"){
					document.getElementById(id).style.backgroundColor = "red";
				}else{
					document.getElementById(id).style.backgroundColor = "white";

				}
			}
		</script>
	</head>
	<body>
		<table border="1" width="500" height="50" align="center" >
			<thead>
				<tr >
					<th>编号</th>
					<th>姓名</th>
					<th>年龄</th>
				</tr>
			</thead>
			<tbody>
				<tr id="tr1" onmouseover="changeColor('tr1','up')" onmouseout="changeColor('tr1','close')">
					<td>1</td>
					<td>张三</td>
					<td>22</td>
				</tr>
				<tr id="tr2" onmouseover="changeColor('tr2','up')" onmouseout="changeColor('tr2','close')">
					<td>2</td>
					<td>李四</td>
					<td>25</td>
				</tr>
				<tr id="tr3" onmouseover="changeColor('tr3','up')" onmouseout="changeColor('tr3','close')">
					<td>3</td>
					<td>王五</td>
					<td>27</td>
				</tr>
				<tr id="tr4" onmouseover="changeColor('tr4','up')" onmouseout="changeColor('tr4','close')">
					<td>4</td>
					<td>赵六</td>
					<td>29</td>
				</tr>
				<tr id="tr5" onmouseover="changeColor('tr5','up')" onmouseout="changeColor('tr5','close')">
					<td>5</td>
					<td>田七</td>
					<td>30</td>
				</tr>
				<tr id="tr6" onmouseover="changeColor('tr6','up')" onmouseout="changeColor('tr6','close')">
					<td>6</td>
					<td>汾九</td>
					<td>20</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>
